<?php
session_start();
//Generate URL
function genURL($x) {
	//Find Address
	//Uncomment for full URL
	#$docurl = "http://";
	#$docurl .= $_SERVER['SERVER_NAME'];
	
	//Find Path
	$docpath = $_SERVER['PHP_SELF'];
	
	//Explode all slashes
	$docexp = explode("/",$docpath);
	
	//Find Length of File Name (Last Value in Exploded Array)
	$doclen = strlen(end($docexp));
	
	//URL Of Document without file name
	$doclean = substr($docpath, 0, -$doclen);
	
	//Return URL
	//Add $docurl before $doclean for full URL.
	return "".$doclean . $x."/";	
}

//Move to respective page.
if (isset($_SESSION['logged_in'])) {
	header("HTTP/1.1 301 Moved Permanently", TRUE, 301);
	header("Location: ".genURL("home")."");
}
else {
	header("Location: ".genURL("login")."");
}
?>